"""
@author: zjc
@file: 链表反转.py
@time: 2022/12/3 17:29
"""
class jd():
    def __init__(self,data):
        self.data=data
        self.next=None

class Linklist():
    def __init__(self,jd):
        self.head=jd
        self.head.next=None
        self.tail=self.head

    def add(self,jd):
        self.tail.next=jd
        self.tail=self.tail.next

    def view(self):
        jd=self.head
        linkstr=""
        while jd is not None:
            if jd.next is not None:
                linkstr=linkstr+str(jd.data)+"-->"
            else:
                linkstr=linkstr+str(jd.data)
            jd=jd.next
        print(linkstr)

lst=[1,"hello",89,"hahaha",47]
lst.reverse()
lst_jd=[]
for i in lst:
    lst_jd.append(jd(i))
lst1=Linklist(lst_jd[0])
for j in lst_jd:
    lst1.add(j)
lst1.view()